{% extends "nomcom/nomcom_private_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin static %}
{% block subtitle %}- Positions{% endblock %}
{% block nomcom_content %}
    {% origin %}
    <h2 class="mb-3">Positions in {{ nomcom.group }}</h2>
    {% if nomcom.group.state_id == 'active' %}
        <a class="btn btn-primary"
           href="{% url 'ietf.nomcom.views.edit_position' year %}">Add new position</a>
        <p class="my-3">
            If you need to start processing a new position while other positions are further along or have already closed (such as when the 2016 NomCom needed to seat a second RAI AD after moving an incumbent to the IESG chair position) adding a new position is the right way to start. Please review the
            <a href="{% url 'ietf.nomcom.views.configuration_help' year=nomcom.year %}">Configuration Hints</a>.
        </p>
    {% endif %}

    {% if nomcom.group.state_id == 'active' %}
        <form class="form-inline" id="batch-action-form" method="post">
            {% csrf_token %}
    {% endif %}
    {% if positions %}
        <table class="table table-sm table-striped table-hover tablesorter"
               id="position-table">
            <thead>
                <tr>
                    {% if nomcom.group.state_id == 'active' %}
                        <th scope="col">
                            ✓
                        </th>
                        <th scope="col"></th>
                    {% endif %}
                    <th scope="col" data-sort="position">
                        Position
                    </th>
                    <th class="text-center" scope="col" data-sort="iesg">
                        IESG
                    </th>
                    <th class="text-center" scope="col" data-sort="open">
                        Open
                    </th>
                    <th class="text-center" scope="col" data-sort="accept_nom">
                        Accepting Nominations
                    </th>
                    <th class="text-center" scope="col" data-sort="accept_fb">
                        Accepting Feedback
                    </th>
                </tr>
            </thead>
            <tbody>
                <!-- [html-validate-disable-block input-missing-label -- labelled via aria-label] -->
                {% for position in positions %}
                    <tr>
                        {% if nomcom.group.state_id == 'active' %}
                            <td>
                                <input class="batch-select form-check-input"
                                       type="checkbox"
                                       value="{{ position.id }}"
                                       id="id-{{ position.id }}"
                                       aria-label="position.name"
                                       name="selected">
                            </td>
                            <td class="text-nowrap">
                                <a class="btn btn-primary btn-sm"
                                   href="{% url 'ietf.nomcom.views.edit_position' year position.id %}">
                                    Edit
                                </a>
                                <a class="btn btn-danger btn-sm"
                                   href="{% url 'ietf.nomcom.views.remove_position' year position.id %}">
                                    Remove
                                </a>
                            </td>
                        {% endif %}
                        <td>
                            {{ position.name }}
                        </td>
                        <td class="text-center">
                            {{ position.is_iesg_position|yesno:"✓," }}
                        </td>
                        <td class="text-center">
                            {{ position.is_open|yesno:"✓," }}
                        </td>
                        <td class="text-center">
                            {{ position.accepting_nominations|yesno:"✓," }}
                        </td>
                        <td class="text-center">
                            {{ position.accepting_feedback|yesno:"✓," }}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
        {% if nomcom.group.state_id == 'active' %}
            <div class="mb-3">
                <label class="form-label" for="action">
                    Action:
                </label>
                <select class="form-select" name="action" id="action">
                    <option value="" selected="selected">
                        ---------
                    </option>
                    <option value="set_iesg">
                        Is IESG Position: Yes
                    </option>
                    <option value="unset_iesg">
                        Is IESG Position: No
                    </option>
                    <option value="set_open">
                        Is Open: Yes
                    </option>
                    <option value="unset_open">
                        Is Open: No
                    </option>
                    <option value="set_accept_nom">
                        Is Accepting Nominations: Yes
                    </option>
                    <option value="unset_accept_nom">
                        Is Accepting Nominations: No
                    </option>
                    <option value="set_accept_fb">
                        Is Accepting Feedback: Yes
                    </option>
                    <option value="unset_accept_fb">
                        Is Accepting Feedback: No
                    </option>
                </select>
            </div>
            <button class="btn btn-warning"  type="submit" title="Run action">
                Apply
            </button>
        </form>
        {% endif %}
    {% else %}
        <p>
            There are no positions defined.
        </p>
    {% endif %}
{% endblock %}